package bb.lanxing.device.sgdevcie.storage.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import bb.lanxing.R;
import bb.lanxing.databinding.LayoutSgRoutebookManagerItemBinding;
import bb.lanxing.lib.devices.sgsettingentity.routebook.Route;
import java.util.ArrayList;
import java.util.List;
/* compiled from: XossDeviceRouteBookManageAdapter.kt */

public final class XossDeviceRouteBookManageAdapter extends
        BaseQuickAdapter<Route, BaseDataBindingHolder<LayoutSgRoutebookManagerItemBinding>> {
    private boolean isEditMode;

    public XossDeviceRouteBookManageAdapter() {
        super(R.layout.layout_sg_routebook_manager_item, null);
    }

    public final boolean isEditMode() {
        return this.isEditMode;
    }

    public final void setEditMode(boolean z) {
        this.isEditMode = z;
        notifyDataSetChanged();
    }

    @Override
    public void convert(BaseDataBindingHolder<LayoutSgRoutebookManagerItemBinding> holder, final Route item) {
        LayoutSgRoutebookManagerItemBinding dataBinding = holder.getDataBinding();
        if (dataBinding != null) {
            //TODO:hu
//            dataBinding.setIsEditMode(this.isEditMode);
//            dataBinding.setRoute(item);

            dataBinding.llRoot.setOnClickListener(view -> {
                if (isEditMode) {
                    item.setChecked(!item.getChecked());
                    notifyItemChanged(getItemPosition(item));
                }
            });
            dataBinding.checkbox.setChecked(item.getChecked());
        }
    }

    public final void checkAll() {
        for (Route route : getData()) {
            route.setChecked(true);
        }
        notifyDataSetChanged();
    }

    public final void clearChecked() {
        for (Route route : getData()) {
            route.setChecked(false);
        }
        notifyDataSetChanged();
    }

    public final List<Route> getCheckedItem() {
        ArrayList arrayList = new ArrayList();
        for (Route obj : getData()) {
            if (obj.getChecked()) {
                arrayList.add(obj);
            }
        }
        return arrayList;
    }
}
